﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using Dexter.Web.Mvc.ViewModel.Resources;

namespace Dexter.Web.Mvc.ViewModel.Backoffice.Binders {
	public class FastPostBinder {
		public int Id { get; set; }

		[Required ( ErrorMessageResourceType = typeof ( Errors ), ErrorMessageResourceName = "RequiredField" )]
		public string Title { get; set; }
		public string Abstract { get; set; }
		public string Slug { get; set; }
		public bool BreakOnAggregate { get; set; }
		public bool CommentEnabled { get; set; }

		[DisplayFormat ( ApplyFormatInEditMode = true, DataFormatString = "{0:dd MMMM yyyy}" )]
		public DateTime PublishDate { get; set; }

		public int PublishHour { get; set; }
		public int PublishMinutes { get; set; }
		
		public int? CategoryId { get; set; }

		[AllowHtml]
		[Required ( ErrorMessageResourceType = typeof ( Errors ), ErrorMessageResourceName = "RequiredField" )]
		public string FormattedBody { get; set; }

		public bool Publish { get; set; }

		[Required ( ErrorMessageResourceType = typeof ( Errors ), ErrorMessageResourceName = "RequiredField" )]
		public string Tags { get; set; }

		public static FastPostBinder EmptyInstance ( ) {
			return new FastPostBinder {
				PublishDate = DateTime.Now,
				PublishHour = DateTime.Now.Hour,
				PublishMinutes = DateTime.Now.Minute,
				Publish = true,
				CommentEnabled = true
			};
		}
	}
}